package vnu.edu.news.helpper;

public class SOAPRequestMaker {
	public static String makeSOAPRequest1(int sportPriority,
			int technologyPriority) {
		StringBuffer result = new StringBuffer(
				"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<soapenv:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:MathFunctions\">\n<soapenv:Header/>\n<soapenv:Body>\n<urn:sum soapenv:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\n<firstElement xsi:type=\"xsd:float\">");
		if (!(sportPriority >= 0 && sportPriority <= 10
				&& technologyPriority >= 0 && technologyPriority <= 10)) {
			sportPriority = 5;
			technologyPriority = 5;
		}
		result.append("" + sportPriority);
		result.append("</firstElement>\n<secondElement xsi:type=\"xsd:float\">");
		result.append("" + technologyPriority);
		result.append("</secondElement>\n</urn:sum>\n</soapenv:Body>\n</soapenv:Envelope>\n");
		return result.toString().trim();
	}

	public static String makeSOAPRequest(String userName,
			int technologyPriority, int sportPriority) {
		if (!(sportPriority >= 0 && sportPriority <= 10
				&& technologyPriority >= 0 && technologyPriority <= 10)) {
			sportPriority = 5;
			technologyPriority = 5;
		}

		if (userName.length() == 0) {
			userName = "Default User";
		}

		StringBuffer result = new StringBuffer(
				"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<soapenv:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:NewsServicesFunction\">\n<soapenv:Header/>\n<soapenv:Body>\n<urn:newsMaker soapenv:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\n<userNameElement xsi:type=\"xsd:string\">");// \n<firstElement
		// xsi:type=\"xsd:float\">");
		result.append(userName
				+ "</userNameElement>\n<sportPriorityElement xsi:type=\"xsd:float\">");
		result.append("" + sportPriority);
		result.append("</sportPriorityElement>\n<technologyPriorityElement xsi:type=\"xsd:float\">");
		result.append("" + technologyPriority);
		result.append("</technologyPriorityElement>\n</urn:newsMaker>\n</soapenv:Body>\n</soapenv:Envelope>\n");
		return result.toString().trim();
	}
}
